<?php
require_once 'DAL.php';
require_once 'Attendee.php';
require_once 'data class/ContactInfo.php';
require_once 'data class/MembershipInfo.php';
require_once 'data class/NollekitInfo.php';
require_once 'data class/OverallInfo.php';
require_once 'data class/SittningInfo.php';

class EditModel {

	private $DAL;

	function __construct() {
		$this -> DAL = new DAL();
	}

	/**
	 * @return boolean Returns true if the complete attendee list should be shown
	 */
	public function listOrEdit() {
		return TRUE;
	}

	/**
	 * @return Array returns an array containing all the attendees
	 */
	public function getAttendeeArray() {
		//Tänk på att den här arrayen inte innehåller betalinfo
		$attendeeArray;
		$rawAttendeeArray = $this -> DAL -> getAttendees();
		foreach ($rawAttendeeArray as $a => $currentAttendee) {
			$tempAttendee = new Attendee($currentAttendee[0], $currentAttendee[1], $currentAttendee[2]);

			$contactInfoArray = $this -> DAL -> getMemberInfo($currentAttendee[0], "kontakt");
			$tempAttendee -> contactInfo = new ContactInfo($contactInfoArray[1], $contactInfoArray[2], $contactInfoArray[3]);

			$membershipInfoArray = $this -> DAL -> getMemberInfo($currentAttendee[0], "medlemskap");
			$tempAttendee -> membershipInfo = new MembershipInfo($membershipInfoArray[1], $membershipInfoArray[2]);

			$nollekitInfoArray = $this -> DAL -> getMemberInfo($currentAttendee[0], "nollekit");
			$tempAttendee -> NollekitInfo = new NollekitInfo($nollekitInfoArray[1], $nollekitInfoArray[2], $nollekitInfoArray[3]);
			
			$overallInfoArray = $this -> DAL -> getMemberInfo($currentAttendee[0], "overall");
			$tempAttendee -> overallInfo = new OverallInfo($overallInfoArray[1], $overallInfoArray[2], $overallInfoArray[3]);
			
			$sittning1InfoArray = $this -> DAL -> getMemberInfo($currentAttendee[0], "sittning1");
			$tempAttendee -> sittning1Info = new SittningInfo($sittning1InfoArray[1], $sittning1InfoArray[2]);
			
			$sittning2InfoArray = $this -> DAL -> getMemberInfo($currentAttendee[0], "sittning2");
			$tempAttendee -> sittning2Info = new SittningInfo($sittning2InfoArray[1], $sittning2InfoArray[2]);
			
			$sittning3InfoArray = $this -> DAL -> getMemberInfo($currentAttendee[0], "sittning3");
			$tempAttendee -> sittning1Info = new SittningInfo($sittning3InfoArray[1], $sittning3InfoArray[2]);

			$attendeeArray[] = $tempAttendee;
		}
		return $attendeeArray;
	}

	/**
	 * @param $$socialSecurityNumber
	 * @return Array returns an array containing a boolean and a date
	 */
	public function getPaymentInfo() {
		//Gör en funktion för varje tabell
	}

}
